TK!2
=v
#1
:n
L1
:v
10
:s
i
:c
spring length
#2
:n
L2
:v
10
:s
i
:c
   "     "
#3
:n
K1
:v
8
:s
i
:c
spring stiffness
#4
:n
K2
:v
1
:s
i
:c
   "      "
#5
:n
P1
:v
5
:s
i
:c
load in x1 direction
#6
:n
P2
:v
5
:s
i
:c
load in x2 direction
#7
:n
x1
:v
10
:s
g
:c
coordinate, unknown
#8
:n
x2
:v
10
:s
g
:c
coordinate, unknown
#9
:n
PE
:s
b
:c
potential energy, objective function
#11
:n
dx
:v
.00001
:s
i
:c
differentiation increment (should be
#12
:n

:s
b
:c
greater than the Comparison Tolerance
#13
:n

:s
b
:c
on the Global Sheet)
=u
=l
=f
#1
:n
springs
:c
Potential energy of a two-spring system
:t
Rule
:p
L1,L2,K1,K2,P1,P2
:a
x1,x2
:v
PE
#1
:n
springs
:z
pe1 = K1*(sqrt(x1^2+(L1-x2)^2) - L1)^2
pe2 = K2*(sqrt(x1^2+(L2+x2)^2) - L2)^2
PE = (pe1+pe2)/2 - P1*x1 - P2*x2

" Note: This function returns the potential energy of a two-spring system.
"       The springs with lengths L1 and L2 and stiffnesses K1 and K2 are
"       loaded with forces P1 and P2 along the x- and y-axes; the potential
"       energy is a function of the displacements x1 and x2.

"                                 P2
"                                ³
"                                ÀÄÄÄÄ P1
"                  ±oÄ@@@@@@@@@@ÄoÄ@@@@@@@@@@Äo±
/E
E
=r
#1
:r
" ***  Multidimensional Optimization, Part 2  ***
:s
C
#3
:r
PE = springs(x1,x2)
#4
:r
PE = springs(x1*(1+dx),x2)
#5
:r
PE = springs(x1,x2*(1+dx))
#7
:r
" This model solves the optimization problem described in model OPTIM2A
:s
C
#8
:r
" using numerical approximation of the partial derivatives of objective
:s
C
#9
:r
" function  PE  with respect to the unknowns  x1  and  x2 . 
:s
C
#11
:r
" The three rules above (using the objective function definition in the rule
:s
C
#12
:r
" function  springs ) express the condition of the first partial derivatives
:s
C
#13
:r
" of PE with respect to  x1  and  x2  being zero.  This treatment is similar
:s
C
#14
:r
" to that discussed in model OPT1B except that here we use relative incre-  
:s
C
#15
:r
" ments (an important point in the multidimensional situation).
:s
C
#17
:r
" Assign, say, dx=.00001 and guess values x1=x2=10, and solve (F9).  The
:s
C
#18
:r
" solution will be found in 6 iteration steps.  The numerical differentiation
:s
C
#19
:r
" approach may be quite sensitive to the choice of guesses.  We found that
:s
C
#20
:r
" this model works well when the guesses are larger than the final results.
:s
C
=p
=t
#1
:s
Screen
:v
Vertical
:f
1
:r
""
:c
""
:t
""
:u
#1
:l
abc
:w
10
:h
""
#2
:l
cba
:w
10
:h
""
#3
:l
xyz
:w
10
:h
""
#4
:l
prs
:w
10
:h
""
E
=n
=g
#1
:c
.000001
:i
10
:v
Yes
:l
60
:f
66
:m
0
:w
80
:b
Yes
:a
Yes
:r
Yes
:h
No
:t
1
:n
Yes
:d
LPT1
%Tr,f,0,1,0,1,0
